<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 定义数据 -->
    <button class="but1">-1</button>
    <input type="text" name="" id=""value="0">
    <button class="but2">+1</button>
</body>
<script>
    //绑定事件源
    let text=document.querySelector("input");
    let but1=document.querySelector(".but1");
    let but2=document.querySelector(".but2");
    //绑定事件类型
    console.log(text.innerHTML);
    but1.onclick=function(){
        text.value-=1;
    }
    but2.onclick=function(){
        let num1=parseInt(text.value)
        num1+=1;
        text.value=num1;
    }
</script>
</html>